home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / aminet / dev / lang / pcq12b.lzh / Include / Devices / TrackDisk.i < prev   
Text File  |  1990-08-27  |  5KB  |  186 lines

  1. {
  2.     Trackdisk.i for PCQ Pascal
  3. }
  4.  
  5. {$I "Include:Exec/IO.i"}
  6. {$I "Include:Exec/Devices.i"}
  7.  
  8. {
  9.  *--------------------------------------------------------------------
  10.  *
  11.  * Physical drive constants
  12.  *
  13.  *--------------------------------------------------------------------
  14. }
  15.  
  16. Const
  17.  
  18.     NUMSECS    = 11;
  19.     NUMUNITS    = 4;
  20.  
  21. {
  22.  *--------------------------------------------------------------------
  23.  *
  24.  * Useful constants
  25.  *
  26.  *--------------------------------------------------------------------
  27.  }
  28.  
  29. {-- sizes before mfm encoding }
  30.     TD_SECTOR    = 512;
  31.     TD_SECSHIFT    = 9;        { log TD_SECTOR }
  32.  
  33. {
  34.  *--------------------------------------------------------------------
  35.  *
  36.  * Driver Specific Commands
  37.  *
  38.  *--------------------------------------------------------------------
  39.  }
  40.  
  41. {
  42.  *-- TD_NAME is a generic macro to get the name of the driver.    This
  43.  *-- way if the name is ever changed you will pick up the change
  44.  *-- automatically.
  45.  *--
  46.  *-- Normal usage would be:
  47.  *--
  48.  *-- char internalName[] = TD_NAME;
  49.  *--
  50.  }
  51.  
  52.     TD_NAME    = "trackdisk.device";
  53.  
  54.     TDF_EXTCOM    = $00010000;        { for internal use only! }
  55.  
  56.  
  57.     TD_MOTOR        = CMD_NONSTD + 0;    { control the disk's motor }
  58.     TD_SEEK        = CMD_NONSTD + 1;    { explicit seek (for testing) }
  59.     TD_FORMAT        = CMD_NONSTD + 2;    { format disk }
  60.     TD_REMOVE        = CMD_NONSTD + 3;    { notify when disk changes }
  61.     TD_CHANGENUM    = CMD_NONSTD + 4;    { number of disk changes }
  62.     TD_CHANGESTATE    = CMD_NONSTD + 5;    { is there a disk in the drive? }
  63.     TD_PROTSTATUS    = CMD_NONSTD + 6;    { is the disk write protected? }
  64.     TD_RAWREAD        = CMD_NONSTD + 7;    { read raw bits from the disk }
  65.     TD_RAWWRITE        = CMD_NONSTD + 8;    { write raw bits to the disk }
  66.     TD_GETDRIVETYPE    = CMD_NONSTD + 9;    { get the type of the disk drive }
  67.     TD_GETNUMTRACKS    = CMD_NONSTD + 10;    { # of tracks for this type drive }
  68.     TD_ADDCHANGEINT    = CMD_NONSTD + 11;    { TD_REMOVE done right }
  69.     TD_REMCHANGEINT    = CMD_NONSTD + 12;    { remove softint set by ADDCHANGEINT }
  70.  
  71.     TD_LASTCOMM        = CMD_NONSTD + 13;
  72.  
  73. {
  74.  *
  75.  * The disk driver has an "extended command" facility.    These commands
  76.  * take a superset of the normal IO Request block.
  77.  *
  78.  }
  79.  
  80.     ETD_WRITE        = CMD_WRITE + TDF_EXTCOM;
  81.     ETD_READ        = CMD_READ + TDF_EXTCOM;
  82.     ETD_MOTOR        = TD_MOTOR + TDF_EXTCOM;
  83.     ETD_SEEK        = TD_SEEK + TDF_EXTCOM;
  84.     ETD_FORMAT        = TD_FORMAT + TDF_EXTCOM;
  85.     ETD_UPDATE        = CMD_UPDATE + TDF_EXTCOM;
  86.     ETD_CLEAR        = CMD_CLEAR + TDF_EXTCOM;
  87.     ETD_RAWREAD        = TD_RAWREAD + TDF_EXTCOM;
  88.     ETD_RAWWRITE    = TD_RAWWRITE + TDF_EXTCOM;
  89.  
  90. {
  91.  *
  92.  * extended IO has a larger than normal io request block.
  93.  *
  94.  }
  95.  
  96. Type
  97.  
  98.     IOExtTD = record
  99.     iotd_Req    : IOStdReq;
  100.     iotd_Count    : Integer;
  101.     iotd_SecLabel    : Integer;
  102.     end;
  103.     IOExtTDPtr = ^IOExtTD;
  104.  
  105.  
  106. Const
  107.  
  108. {
  109. ** raw read and write can be synced with the index pulse.  This flag
  110. ** in io request's IO_FLAGS field tells the driver that you want this.
  111. }
  112.  
  113.     IOTDB_INDEXSYNC    = 4;
  114.     IOTDF_INDEXSYNC    = 16;
  115.  
  116.  
  117. { labels are TD_LABELSIZE bytes per sector }
  118.  
  119.     TD_LABELSIZE    = 16;
  120.  
  121. {
  122. ** This is a bit in the FLAGS field of OpenDevice.  If it is set, then
  123. ** the driver will allow you to open all the disks that the trackdisk
  124. ** driver understands.    Otherwise only 3.5" disks will succeed.
  125. }
  126.  
  127.     TDB_ALLOW_NON_3_5    = 0;
  128.     TDF_ALLOW_NON_3_5    = 1;
  129.  
  130. {
  131. **  If you set the TDB_ALLOW_NON_3_5 bit in OpenDevice, then you don't
  132. **  know what type of disk you really got.  These defines are for the
  133. **  TD_GETDRIVETYPE command.  In addition, you can find out how many
  134. **  tracks are supported via the TD_GETNUMTRACKS command.
  135. }
  136.  
  137.     DRIVE3_5        = 1;
  138.     DRIVE5_25        = 2;
  139.  
  140. {
  141.  *--------------------------------------------------------------------
  142.  *
  143.  * Driver error defines
  144.  *
  145.  *--------------------------------------------------------------------
  146.  }
  147.  
  148.     TDERR_NotSpecified        = 20;    { general catchall }
  149.     TDERR_NoSecHdr        = 21;    { couldn't even find a sector }
  150.     TDERR_BadSecPreamble    = 22;    { sector looked wrong }
  151.     TDERR_BadSecID        = 23;    { ditto }
  152.     TDERR_BadHdrSum        = 24;    { header had incorrect checksum }
  153.     TDERR_BadSecSum        = 25;    { data had incorrect checksum }
  154.     TDERR_TooFewSecs        = 26;    { couldn't find enough sectors }
  155.     TDERR_BadSecHdr        = 27;    { another "sector looked wrong" }
  156.     TDERR_WriteProt        = 28;    { can't write to a protected disk }
  157.     TDERR_DiskChanged        = 29;    { no disk in the drive }
  158.     TDERR_SeekError        = 30;    { couldn't find track 0 }
  159.     TDERR_NoMem            = 31;    { ran out of memory }
  160.     TDERR_BadUnitNum        = 32;    { asked for a unit > NUMUNITS }
  161.     TDERR_BadDriveType        = 33;    { not a drive that trackdisk groks }
  162.     TDERR_DriveInUse        = 34;    { someone else allocated the drive }
  163.     TDERR_PostReset        = 35;    { user hit reset; awaiting doom }
  164.  
  165. {
  166.  *--------------------------------------------------------------------
  167.  *
  168.  * public portion of the unit structure
  169.  *
  170.  *--------------------------------------------------------------------
  171.  }
  172.  
  173. Type
  174.  
  175.     TDU_PublicUnit = record
  176.     tdu_Unit    : Unit;        { base message port }
  177.     tdu_Comp01Track    : Short;    { track for first precomp }
  178.     tdu_Comp10Track    : Short;    { track for second precomp }
  179.     tdu_Comp11Track    : Short;    { track for third precomp }
  180.     tdu_StepDelay    : Integer;    { time to wait after stepping }
  181.     tdu_SettleDelay    : Integer;    { time to wait after seeking }
  182.     tdu_RetryCnt    : Byte;        { # of times to retry }
  183.     end;
  184.     TDU_PublicUnitPtr = ^TDU_PublicUnit;
  185.  
  186.